﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.WaitForSecondsRealtime
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

#nullable disable
namespace UnityEngine
{
  /// <summary>
  ///   <para>Suspends the coroutine execution for the given amount of seconds using unscaled time.</para>
  /// </summary>
  public class WaitForSecondsRealtime : CustomYieldInstruction
  {
    private float m_WaitUntilTime = -1f;

    /// <summary>
    ///   <para>The given amount of seconds that the yield instruction will wait for.</para>
    /// </summary>
    public float waitTime { get; set; }

    public override bool keepWaiting
    {
      get
      {
        if ((double) this.m_WaitUntilTime < 0.0)
          this.m_WaitUntilTime = Time.realtimeSinceStartup + this.waitTime;
        bool keepWaiting = (double) Time.realtimeSinceStartup < (double) this.m_WaitUntilTime;
        if (!keepWaiting)
          this.Reset();
        return keepWaiting;
      }
    }

    /// <summary>
    ///   <para>Creates a yield instruction to wait for a given number of seconds using unscaled time.</para>
    /// </summary>
    /// <param name="time"></param>
    public WaitForSecondsRealtime(float time) => this.waitTime = time;

    public override void Reset() => this.m_WaitUntilTime = -1f;
  }
}
